package com.example.factory.api.controller;

import com.example.factory.api.dto.DtoFactory;
import com.example.factory.api.dto.Response;
import com.example.factory.api.dto.form.DtoFactoryForm;
import com.example.factory.api.facade.FactoryFacade;
import org.springframework.web.bind.annotation.*;

/**
 * @author Lei Tao
 */
@RestController
@RequestMapping("/admin/factory")
public class FactoryController {
    private final FactoryFacade factoryFacade;

    public FactoryController(FactoryFacade factoryFacade) {
        this.factoryFacade = factoryFacade;
    }

    @PostMapping("/update")
    public Response<DtoFactory> updateFactory(@RequestBody DtoFactoryForm dtoFactoryForm) {
        return factoryFacade.updateFactory(dtoFactoryForm);
    }

    @GetMapping("/retrieve")
    public Response<DtoFactory> retrieveFactory() {
        return factoryFacade.retrieveFactory();
    }
}
